Executes the Hacker News and AlchemyAPI.ipynb
notebook to aggregate data over time. Meant to be left running indefinitely in the background so that the job scheduler can execute once a day.
You can use this pattern of running notebooks on a pre-defined schedules in your own notebooks that collect data or compute analysis over time.
!pip install schedule
!pip install runipy
In [ ]:
import schedule
import time
import subprocess
In [ ]:
NOTEBOOK_FILENAME = 'Hacker News and AlchemyAPI.ipynb'
In [ ]:
def run_notebook():
subprocess.check_call(['runipy', '-o', NOTEBOOK_FILENAME])
In [ ]:
def aggregate_hacker_news_data():
try:
run_notebook()
except Exception:
import traceback
traceback.print_exc()
In [ ]:
schedule.every().hour.do(aggregate_hacker_news_data)
#schedule.every().minute.do(aggregate_hacker_news_data)
In [ ]:
while True:
schedule.run_pending()
time.sleep(30)
In [ ]: